home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-ARM / IO.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  5KB  |  193 lines

  1. /*
  2.  * linux/include/asm-arm/io.h
  3.  *
  4.  * Copyright (C) 1996 Russell King
  5.  *
  6.  * Modifications:
  7.  *  16-Sep-1996    RMK    Inlined the inx/outx functions & optimised for both
  8.  *            constant addresses and variable addresses.
  9.  *  04-Dec-1997    RMK    Moved a lot of this stuff to the new architecture
  10.  *            specific IO header files.
  11.  */
  12. #ifndef __ASM_ARM_IO_H
  13. #define __ASM_ARM_IO_H
  14.  
  15. #include <asm/hardware.h>
  16. #include <asm/arch/mmu.h>
  17. #include <asm/arch/io.h>
  18. #include <asm/proc/io.h>
  19.  
  20. /* unsigned long virt_to_phys(void *x) */
  21. #define virt_to_phys(x)        (__virt_to_phys((unsigned long)(x)))
  22.  
  23. /* void *phys_to_virt(unsigned long x) */
  24. #define phys_to_virt(x)        ((void *)(__phys_to_virt((unsigned long)(x))))
  25.  
  26. /*
  27.  * Virtual view <-> DMA view memory address translations
  28.  * virt_to_bus: Used to translate the virtual address to an
  29.  *              address suitable to be passed to set_dma_addr
  30.  * bus_to_virt: Used to convert an address for DMA operations
  31.  *              to an address that the kernel can use.
  32.  */
  33. #define virt_to_bus(x)    (__virt_to_bus((unsigned long)(x)))
  34. #define bus_to_virt(x)    ((void *)(__bus_to_virt((unsigned long)(x))))
  35.  
  36. /*
  37.  * These macros actually build the multi-value IO function prototypes
  38.  */
  39. #define __OUTS(s,i,x)    extern void outs##s(unsigned int port, const void *from, int len);
  40. #define __INS(s,i,x)    extern void ins##s(unsigned int port, void *to, int len);
  41.  
  42. #define __IO(s,i,x) \
  43.   __OUTS(s,i,x) \
  44.   __INS(s,i,x)
  45.  
  46. __IO(b,"b",char)
  47. __IO(w,"h",short)
  48. __IO(l,"",long)
  49.  
  50. /*
  51.  * Note that due to the way __builtin_constant_t() works, you
  52.  *  - can't use it inside an inline function (it will never be true)
  53.  *  - you don't have to worry about side effects withing the __builtin..
  54.  */
  55. #ifdef __outbc
  56. #define outb(val,port)    \
  57.   (__builtin_constant_p((port)) ? __outbc((val),(port)) : __outb((val),(port)))
  58. #else
  59. #define outb(val,port) __outb((val),(port))
  60. #endif
  61.  
  62. #ifdef __outwc
  63. #define outw(val,port)    \
  64.   (__builtin_constant_p((port)) ? __outwc((val),(port)) : __outw((val),(port)))
  65. #else
  66. #define outw(val,port) __outw((val),(port))
  67. #endif
  68.  
  69. #ifdef __outlc
  70. #define outl(val,port)    \
  71.   (__builtin_constant_p((port)) ? __outlc((val),(port)) : __outl((val),(port)))
  72. #else
  73. #define outl(val,port) __outl((val),(port))
  74. #endif
  75.  
  76. #ifdef __inbc
  77. #define inb(port)    \
  78.   (__builtin_constant_p((port)) ? __inbc((port)) : __inb((port)))
  79. #else
  80. #define inb(port) __inb((port))
  81. #endif
  82.  
  83. #ifdef __inwc
  84. #define inw(port)    \
  85.   (__builtin_constant_p((port)) ? __inwc((port)) : __inw((port)))
  86. #else
  87. #define inw(port) __inw((port))
  88. #endif
  89.  
  90. #ifdef __inlc
  91. #define inl(port)    \
  92.   (__builtin_constant_p((port)) ? __inlc((port)) : __inl((port)))
  93. #else
  94. #define inl(port) __inl((port))
  95. #endif
  96.  
  97. /*
  98.  * This macro will give you the translated IO address for this particular
  99.  * architecture, which can be used with the out_t... functions.
  100.  */
  101. #define ioaddr(port)    \
  102.   (__builtin_constant_p((port)) ? __ioaddrc((port)) : __ioaddr((port)))
  103.  
  104. #ifndef ARCH_IO_DELAY
  105. /*
  106.  * This architecture does not require any delayed IO.
  107.  * It is handled in the hardware.
  108.  */
  109. #define outb_p(val,port)    outb((val),(port))
  110. #define outw_p(val,port)    outw((val),(port))
  111. #define outl_p(val,port)    outl((val),(port))
  112. #define inb_p(port)        inb((port))
  113. #define inw_p(port)        inw((port))
  114. #define inl_p(port)        inl((port))
  115. #define outsb_p(port,from,len)    outsb(port,from,len)
  116. #define outsw_p(port,from,len)    outsw(port,from,len)
  117. #define outsl_p(port,from,len)    outsl(port,from,len)
  118. #define insb_p(port,to,len)    insb(port,to,len)
  119. #define insw_p(port,to,len)    insw(port,to,len)
  120. #define insl_p(port,to,len)    insl(port,to,len)
  121.  
  122. #else
  123.  
  124. /*
  125.  * We have to delay the IO...
  126.  */
  127. #ifdef __outbc_p
  128. #define outb_p(val,port)    \
  129.   (__builtin_constant_p((port)) ? __outbc_p((val),(port)) : __outb_p((val),(port)))
  130. #else
  131. #define outb_p(val,port) __outb_p((val),(port))
  132. #endif
  133.  
  134. #ifdef __outwc_p
  135. #define outw_p(val,port)    \
  136.   (__builtin_constant_p((port)) ? __outwc_p((val),(port)) : __outw_p((val),(port)))
  137. #else
  138. #define outw_p(val,port) __outw_p((val),(port))
  139. #endif
  140.  
  141. #ifdef __outlc_p
  142. #define outl_p(val,port)    \
  143.   (__builtin_constant_p((port)) ? __outlc_p((val),(port)) : __outl_p((val),(port)))
  144. #else
  145. #define outl_p(val,port) __outl_p((val),(port))
  146. #endif
  147.  
  148. #ifdef __inbc_p
  149. #define inb_p(port)    \
  150.   (__builtin_constant_p((port)) ? __inbc_p((port)) : __inb_p((port)))
  151. #else
  152. #define inb_p(port) __inb_p((port))
  153. #endif
  154.  
  155. #ifdef __inwc_p
  156. #define inw_p(port)    \
  157.   (__builtin_constant_p((port)) ? __inwc_p((port)) : __inw_p((port)))
  158. #else
  159. #define inw_p(port) __inw_p((port))
  160. #endif
  161.  
  162. #ifdef __inlc_p
  163. #define inl_p(port)    \
  164.   (__builtin_constant_p((port)) ? __inlc_p((port)) : __inl_p((port)))
  165. #else
  166. #define inl_p(port) __inl_p((port))
  167. #endif
  168.  
  169. #endif
  170.  
  171. #undef ARCH_IO_DELAY
  172. #undef ARCH_IO_CONSTANT
  173.  
  174. #ifdef __KERNEL__
  175.  
  176. extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
  177.  
  178. /*
  179.  * String version of IO memory access ops:
  180.  */
  181. extern void _memcpy_fromio(void *, unsigned long, unsigned long);
  182. extern void _memcpy_toio(unsigned long, void *, unsigned long);
  183. extern void _memset_io(unsigned long, int, unsigned long);
  184.  
  185. #define memcpy_fromio(to,from,len)    _memcpy_fromio((to),(unsigned long)(from),(len))
  186. #define memcpy_toio(to,from,len)    _memcpy_toio((unsigned long)(to),(from),(len))
  187. #define memset_io(addr,c,len)        _memset_io((unsigned long)(addr),(c),(len))
  188.  
  189. #endif
  190.  
  191. #endif
  192.  
  193.